<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/4/15
 * Time: 下午1:46
 */

namespace App\Busi\Modules\Resource;


use App\Busi\Modules\BaseBusi;
use App\Busi\Traits\CatgoryCompanyTrait;
use App\Http\Requests\CompanyListRo;
use App\Busi\Traits\CompanyTrait;
class CompanyListBusi extends BaseBusi
{
    use CompanyTrait,CatgoryCompanyTrait;
    public function handle(CompanyListRo $ro){
        $page = $ro->page;
        $dist_id = $ro->dist_id;
        $category_id = $ro->category_id;
        $tag = $ro->tag;
        //公司首页列表
        if($page && !$dist_id && !$category_id &&!$tag){
            return $this->getCompanyList($page);
        }
        //根据城市id 获取公司
        if($dist_id && $page){

            return $this->getCompanyListByDistId($dist_id);
        }
        //资质id 获取公司列表
        if($category_id && $page){
            $company_ids = $this->getCompanyIdsByCategoryId($category_id);
            return $this->getCompanyListByCompanyIds($company_ids);
        }
        //如果有tag 则按标签获取公司列表
        if($tag && $page){

            return $this->getCompanyListByTag($tag);
        }
        else{
            //展示推荐的4个公司
            return $this->getRecommendCompanyList(4);
        }

    }
}